from media.lib.views import FileUploadFormMixin
from project.views.lib import (
    HTMXProjectSubCreateFormViewNoPK,
    HTMXProjectSubUpdateFormViewNoPK,
    ProjectSubIndexRedirectView,
    ProjectSubDetailViewNoPK,
    template_path
)

from .. import models
from .. import forms

class BeginningIndexView(ProjectSubIndexRedirectView):
    model = models.Beginning
    detail_view_name = "project:beginning/detail"
    create_view_name = "project:beginning/create"

class BeginningCreateView(
    FileUploadFormMixin,
    HTMXProjectSubCreateFormViewNoPK,
):
    form_class = forms.BeginningForm
    template_name = template_path("detail_form_base.html")
    create_view_name = "project:beginning/create"
    detail_view_name = "project:beginning/detail"

class BeginningDetailView(ProjectSubDetailViewNoPK):
    model = models.Beginning
    form_class = forms.BeginningForm
    template_name = template_path("beginning/detail.html")

class BeginningUpdateView(
    FileUploadFormMixin,
    HTMXProjectSubUpdateFormViewNoPK
):
    model = models.Beginning
    form_class = forms.BeginningForm
    update_view_name = "project:beginning/update"
    detail_view_name = "project:beginning/detail"
